using System;
using Wikey.Extensibility.Classes;
using Wikey.Extensibility.Enums;
using Wikey.Extensibility.Interfaces;
using Wikey.Interfaces.Attributes;

namespace Wikey.Transformation.Transformers
{
    [Transformer(Command = "Message")]
    public class MessageTransformer : ITransformer
    {
        public MessageTransformer()
        {
            AcceptDirectParameter = true;    
        }


        public string Command
        {
            get { return "Message"; }
        }

        public TransformationResult Apply(IExpressionFunction function)
        {
            if( !String.IsNullOrEmpty( function.Value ))
            {
                return new TransformationResult(TransformationResultType.Html,  String.Format(Template, function.Value)) ;
            }

            throw new ArgumentNullException("Should have a default value");
        }

        public bool AcceptDirectParameter {
            get;
            set;
        }

        public static string Template = @"<div class='Message'> <h3>{0}</h3> </div>";

        [Parameter(Required = true)]
        public string Text { get; set; }

        [Parameter]
        public string Header { get; set; }
    }
}